package com.fk.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fk.dao.impl.XinWenFenLeiDaoImpl;
import com.fk.dao.impl.XinWenXiangQingDaoImpl;
import com.fk.entity.XinWenFenLei;
import com.fk.entity.XinWenXiangQing;


public class NewsServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//新闻分类
		XinWenFenLeiDaoImpl xwflDao=new XinWenFenLeiDaoImpl();
		List<XinWenFenLei> xwflList=xwflDao.getXinWenFenLeiList();//新闻分类集合
		request.setAttribute("xwflList", xwflList);//存
		
		//根据新闻分类id查询新闻详情
		
		//接受前台传来的参数
		int cId=Integer.parseInt(request.getParameter("xinWenFenLeiId"));
		XinWenXiangQingDaoImpl xwxqDao=new XinWenXiangQingDaoImpl();
		List<XinWenXiangQing> xwxqList=xwxqDao.getXinWenXiangQingList(cId);
		request.setAttribute("xwxqList", xwxqList);
		
		
		
		request.getRequestDispatcher("article_list.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
